package com.lzz.rabbitmq;

import com.lzz.entity.Student;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zhenzhen
 * @date 2018-12-20 下午4:12
 */
@Component
public class HelloSender {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(String data) {
        String context = "hello" + data;
        System.out.println("Sender1:"+context);
        this.rabbitTemplate.convertAndSend("hello", context);
    }

    public void send(Student student) {
        System.out.println("Sender object:" + student.toString());
        this.rabbitTemplate.convertAndSend("object", student.toString());
    }
}
